import { BasicFetchResult } from '/@/api/model/baseMode';
import { defHttp } from '/@/utils/http/axios';
import { ErrorMessageMode } from '/@/utils/http/axios/types';
import {
  QueryParams,
  EditState,
  UrlJoin,
  AddGoods,
  AddActivity,
  AddMerchant,
  ExportParams,
} from './model';
enum Api {
  List = '/baseInfo/businessManager/findPage',
  Edit = '/baseInfo/businessManager/edit',
  Add = '/baseInfo/businessManager/add',
  Delete = '/baseInfo/businessManager/delete/',
  GetInfo = '/baseInfo/businessManager/findById/',
  GoodsQueryApi = '/baseInfo/businessGoodsManager/findPage',
  AddGoods = '/baseInfo/businessGoodsManager/add',
  DeleteGoods = '/baseInfo/businessGoodsManager/delete/',
  ActivityQueryApi = '/baseInfo/timeLimitedActivity/find/',
  getGoodsInfo = '/baseInfo/businessGoodsManager/findById/',
  UpdateGoodsApi = '/baseInfo/businessGoodsManager/edit',
  DeleteActivityApi = '/baseInfo/timeLimitedActivity/delete/',
  UpdateActivityApi = '/baseInfo/timeLimitedActivity/update',
  AddActivityApi = '/baseInfo/timeLimitedActivity/save',
  Export = '/baseInfo/businessManager/export',
}

/**
 * @description: 查询商家列表
 */
export function ListApi(params: QueryParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<BasicFetchResult<any>>(
    {
      url: Api.List,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description:修改商家状态
 */
export function EditStateApi(params: EditState, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicFetchResult<any>>(
    {
      url: Api.Edit,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description:删除商家
 */
export function DeleteApi(params: String, mode: ErrorMessageMode = 'modal') {
  return defHttp.delete<BasicFetchResult<any>>(
    {
      url: Api.Delete + params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description:查看商家信息
 */
export function getInfoApi(params: Number, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<BasicFetchResult<any>>(
    {
      url: Api.GetInfo + params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description:新增商家
 */
export function AddApi(params: AddMerchant, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicFetchResult<any>>(
    {
      url: Api.Add,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description:编辑商家
 */
export function EditApi(params: AddMerchant, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicFetchResult<any>>(
    {
      url: Api.Edit,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description:详细地址
 */
export function AddressApi(params: Number, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<BasicFetchResult<any>>(
    {
      url: Api.Delete + params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description:商品查询
 */
export function GoodsQueryApi(params: QueryParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<BasicFetchResult<any>>(
    {
      url: Api.GoodsQueryApi,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description:商品信息
 */
export function getGoodsInfoApi(params: QueryParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<BasicFetchResult<any>>(
    {
      url: Api.getGoodsInfo + params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description:添加商品
 */
export function AddGoodsApi(params: AddGoods, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicFetchResult<any>>(
    {
      url: Api.AddGoods,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description:编辑商品
 */
export function UpdateGoodsApi(params: AddGoods, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicFetchResult<any>>(
    {
      url: Api.UpdateGoodsApi,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}

/**
 * @description:删除商品
 */
export function DeleteGoodsApi(params: Number, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<BasicFetchResult<any>>(
    {
      url: Api.DeleteGoods + params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description:限时活动查询
 */
export function ActivityQueryApi(params: UrlJoin, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<BasicFetchResult<any>>(
    {
      url: Api.ActivityQueryApi + params.id,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description:添加商品
 */
export function AddActivityApi(params: AddActivity, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicFetchResult<any>>(
    {
      url: Api.AddActivityApi,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description:编辑活动
 */
export function UpdateActivityApi(params: AddActivity, mode: ErrorMessageMode = 'modal') {
  return defHttp.post<BasicFetchResult<any>>(
    {
      url: Api.UpdateActivityApi,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description:删除活动
 */
export function DeleteActivityApi(params: Number, mode: ErrorMessageMode = 'modal') {
  return defHttp.get<BasicFetchResult<any>>(
    {
      url: Api.DeleteActivityApi + params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
/**
 * @description: 导出
 */
export function ExportApi(params: ExportParams, mode: ErrorMessageMode = 'modal') {
  return defHttp.get(
    {
      url: Api.Export,
      params,
    },
    {
      errorMessageMode: mode,
    }
  );
}
